import { WebSocketServer } from "ws";

const wss = new WebSocketServer({ port: 8080 });

wss.on("connection", (socket) => {
  console.log("客户端连接事件:connection~~~");
  socket.on("message", (data) => {
    console.log("客户端发送消息:", data.toString());

    wss.clients.forEach((client) => {
      if (client === socket) return;
      client.send(data.toString());
    });
  });
});
